package com.ypj.indusynergyems.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ypj.indusynergyems.dao.entity.GoodsEntity;
import com.ypj.indusynergyems.dao.mapper.GoodsMapper;
import com.ypj.indusynergyems.service.IGoodsService;
import org.springframework.stereotype.Service;

@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, GoodsEntity> implements IGoodsService {
    @Override
    public String addGoods(GoodsEntity goodsEntity) {
        return baseMapper.insert(goodsEntity)>0?"success":"fail";
    }

    @Override
    public GoodsEntity findById(int goodsId) {
        LambdaQueryWrapper<GoodsEntity> queryWrapper = Wrappers.lambdaQuery(GoodsEntity.class)
                .eq(GoodsEntity::getGodsId, goodsId);

        return baseMapper.selectOne(queryWrapper);
    }
}
